package com.soft.javase.day06.object.equals;

import java.util.Arrays;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/24
 */
public class StudentSystem {
    private Student[] students;
    private int size;

    public StudentSystem() {
        this.students = new Student[10];
        this.size = 0;
    }

    // 添加学生
    public boolean addStudent(Student student) {
        for (int i = 0; i < size; i++) {
            if (students[i].equals(student)) {
                return false;
            }
        }

        // 数组扩容
        if (size == students.length) {
            students = Arrays.copyOf(students, students.length * 3/2+1);
        }

        students[size++] = student;
        return true;
    }
}